package com.songshuai.customer.client.service.impl;

import com.songshuai.customer.client.feign.PanguApiClient;
import com.songshuai.customer.client.service.CustMeetingService;
import com.songshuai.webapi.baseapi.dto.feign.request.custminiprogram.*;
import com.songshuai.webapi.baseapi.dto.feign.response.DictionaryDto;
import com.songshuai.webapi.baseapi.dto.feign.response.custminiprogram.*;
import com.songshuai.webapi.baseapi.enumerations.ResultStatus;
import com.songshuai.webapi.baseapi.pojo.QueryResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author:wbl
 * @Date: 2019/3/20
 */
@Service
public class CustMeetingServiceImpl implements CustMeetingService {

    @Autowired
    private PanguApiClient panguApiClient;

    @Value("${file.basePath}")
    private String basePath;

    @Value("${file.imgPath}")
    private String imgPath;

    @Value("${file.imgMaxSize}")
    private int imgMaxSize;


    @Override
    public QueryResponse<List<MeetingListResDto>> getMeetingListByUserId(String customId) {
        QueryResponse<List<MeetingListResDto>> response = panguApiClient.getMeetingListByUserId(customId);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse<MeetingDetailResDto> getMeetingDetail(MeetingDetailReqDto parm) {
        QueryResponse<MeetingDetailResDto> response =  panguApiClient.getMeetingDetail(parm);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse<List<InvitationTemplateResDto>> getInvitationTemplateByCode(String meetingCode) {
        QueryResponse<List<InvitationTemplateResDto>> response = panguApiClient.getInvitationTemplateByCode(meetingCode);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse<WxQRCodeResDto> getWxQRCode(WxQRCodeReqDto parm) {
        QueryResponse<WxQRCodeResDto> response = panguApiClient.getWxQRCode(parm);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    /*@Override
    public Boolean registerSign(Long clueguid,String meetingno,String timestamp,String hashcode){
        QueryResponse<Boolean> response = panguApiClient.registerSign(clueguid,meetingno,timestamp,hashcode);
        if(response != null){
            return response.getData();
        }
        return null;
    }*/

    /*@Override
    public Boolean QRCodeSign(QRCodeSignReqDto parm) {
        QueryResponse<Boolean> response = panguApiClient.QRCodeSign(parm);
        if(response != null){
            return response.getData();
        }
        return null;
    }*/

    @Override
    public QueryResponse<MeetingReceiptResDto> getMeetingReceipt(MeetingReceiptReqDto parm) {
        QueryResponse<MeetingReceiptResDto> response = panguApiClient.getMeetingReceipt(parm);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse<AddMeetingReceiptResDto> addMeetingReceipt(AddMeetingReceiptReqDto parm) {
        QueryResponse<AddMeetingReceiptResDto> response = panguApiClient.addMeetingReceipt(parm);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_CREATE_FAILED);
    }

    @Override
    public QueryResponse<List<DictionaryDto>> getDictionaryByTypeId(Integer dicType) {
        QueryResponse<List<DictionaryDto>> response = panguApiClient.queryDictionariesByType(dicType);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse<List<StationResDto>> getAreaStations(String meetingCode) {
        QueryResponse<List<StationResDto>> response = panguApiClient.getAreaStations(meetingCode);
        if(response != null){
            return response;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse uploadPicture(MultipartFile file) {
        return panguApiClient.uploadPicture(file,imgMaxSize,basePath,imgPath);
    }

    @Override
    public QueryResponse uploadPictureOss(MultipartFile file) {
        return panguApiClient.uploadPictureOss(file);
    }
}
